package com.class05;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
//        请求域
        req.setAttribute("name", "Tom");
//        会话域
        req.getSession().setAttribute("age", 18);
//        应用程序域
        this.getServletContext().setAttribute("address", "北京");

//        转发之后，ServletB可以获取ServletA往域中添加数据
//        req.getRequestDispatcher("/servletB").forward(req, resp);


        resp.sendRedirect("/servletB");

//


    }
}
